import scrapy
from en.items import EnItem

class EeSpider(scrapy.Spider):
    name = 'ee'
    # allowed_domains = ['ee.com']

    # start_urls = ['http://ee.com/']

    def start_requests(self):
        data = {
            'r': '0.6080521628204734',
            'UserID': '',
            'DateSort': 'Year',
            'Date': '2020',
            'sDate': '2020',
            'eDate': '2020',
            'Index': '102,201,202,605',
            'Line': '',
            'City': '',
            'CityLevel': '',
            'ServicePrice': '1',
            'PageIndex': '1',
            'PageSize': '20',
            'Order': '201',
            'OrderType': 'DESC'
        }

        for page in range(1, 71):
        # for page in range(1, 2):
            data['PageIndex'] = str(page)
            yield scrapy.FormRequest(
                url='https://app.endata.com.cn/API/DataBox/Movie/GetMovieYearBoxOfficeList',
                formdata=data,
                callback=self.parse
            )

    def parse(self, response):
        ei = EnItem()
        res = response.text
        ei['data'] = res
        yield ei